﻿using System.ComponentModel.DataAnnotations;

namespace MvcBook.Models
{
    public class Book
    {
        public int Id { get; set; } // 主键

        [Required(ErrorMessage = "书籍名称必填")]
        [StringLength(20, MinimumLength = 1, ErrorMessage = "1-20个字符")]
        [Display(Name = "书籍名称")]
        public string? Title { get; set; } // 书籍名称

        [Display(Name = "作者")]
        public string? Author { get; set; } // 作者

        [Display(Name ="出版社名")]
        public string? Publisher { get; set; } // 出版社名

        [Required(ErrorMessage = "出版日期必填")]
        [Display(Name = "出版日期")]
        [DataType(DataType.Date)]
        public DateTime PublishingTime { get; set; } // 出版日期

        [Required(ErrorMessage = "书籍价格必填")]
        [Range(1, 200, ErrorMessage = "1-200之间")]
        [Display(Name = "价格")]
        [DataType(DataType.Currency)]
        public decimal Price { get; set; } // 价格

    }
}
